package com.newer.his.common.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.newer.his.common.entity.Checkout;
@Mapper
public interface CheckoutMapper {
	
	

	@Options(useGeneratedKeys = true, 
			keyColumn = " checkout_id", 
			keyProperty = "id")
	@Insert("insert into checkout"
			+ "( cname, encoded, cprice, id_dept, id_unit, position, id_adiveType)"
			+ " values (#{cname},#{encoded},#{cprice},#{id_dept},#{id_unit},#{position},#{id_adiveType})")
	void save(Checkout checkout);
	
	@Select("select checkout_id, cname, encoded, cprice, id_dept, id_unit, position, id_adiveType "
			+ "from checkout where checkout_id=#{checkout_id}")
	Checkout findById(int id);
	
	@Select("select checkout_id, cname, encoded, cprice, id_dept, id_unit, position, id_adiveType from checkout")
	List<Checkout>findAll();
	
	@Update("update checkout set cname=#{cname},encoded=#{encoded},"
			+ "cprice=#{cprice}, id_dept=#{id_dept}, id_unit=#{id_unit},"
			+ " position=#{position}, id_adiveType= #{id_adiveType} where checkout_id=#{checkout_id}")
	void update(Checkout checkout);
	
	@Delete("delete from checkout where checkout_id=#{checkout_id}")
	void delete(int id);
}
